import java.util.Stack;

public class Text2 {
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for (String x : tokens) {
            if (!isoperation(x)) {
                stack.push(Integer.parseInt(x));
            } else {
                int x1 = stack.pop();
                int x2 = stack.pop();
                switch (x) {
                    case "+":
                        stack.push(x2 + x1);
                        break;
                    case "-":
                        stack.push(x2 - x1);
                        break;
                    case "*":
                        stack.push(x2 * x1);
                        break;
                    case "/":
                        stack.push(x2 / x1);
                        break;
                }
            }
        }
        return stack.pop();
    }

    public boolean isoperation(String x) {
        if (x.equals("+")  || x.equals("-") || x.equals("*") || x.equals("/")) {
            return true;
        }
        return false;
    }
}
